package com.xiaoshuidi.cloud.module.member.enums.coupon;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum CouponSendMethodEnum {
    AUTOMATIC (0, "自动发券"),
    MANUAL(1, "手动发券");
    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        CouponSendMethodEnum couponSendMethod = Arrays.stream(CouponSendMethodEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(couponSendMethod != null, "CouponSendMethodEnum:{}不存在", code);
        return couponSendMethod.getName();
    }
}
